<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑老人出院结算单</title>
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
	<#include "/common/resource.ftl">
	<script type="text/javascript">
		$(function () {
            LocalStorage.registHandler("elder_handler_select", function (data) {
                $('input[name="elderId"]').val(data.id);
                $('input[name="elderName"]').val(data.name);
            });
            $.ajaxRequest({
                url: '${params.contextPath}/web/elder/listAll',
                data: {},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var elderStr = "";
                    var record = data.data;
                    for (var i = 0; i < record.length; i++) {
                        elderStr += "<option value="+ record[i].id +">"+ record[i].name +"</option>";
                    }
                    $("#elderId").append(elderStr);
                    layui.form.render();
                }
            });
			<#if (params.id)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/outHospitalReceipt/query.json',
					data: {id: "${params.id}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
						for (var key in record) {
							$("[name='" + key + "']").val(record[key]);
						}
						if (record.status == 2) {
						    $(".layui-btn").addClass("layui-btn-disabled");
                            $(".layui-btn").attr("type", "button");
                        }
						layui.form.render();
					}
				});
			</#if>
		});
	</script>
    <style>
        .layui-form select {display:none !important;}
    </style>
</head>
<body>
	<div class="ui-form">
		<form class="layui-form ajax-form" action="${params.contextPath}/web/outHospitalReceipt/<#if (params.id)??>modify<#else>save</#if>.json" method="post">
			<input type="hidden" name="id" value="${params.id}" />
            <#if (params.tag)??>
                <div class="layui-form-item">
                    <label class="layui-form-label">老人<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <select id="elderId" name="elderId" class="layui-input {required:true}" lay-search></select>
                    </div>
                </div>
            <#else>
                <div class="layui-form-item">
                    <label class="layui-form-label">老人<span class="ui-request">*</span></label>
                    <div class="layui-input-block">
                        <input type="hidden" name="elderId"/>
                        <input type="text" name="elderName" placeholder="请选择老人" p="model:'elder',handlerId:'elder_handler_select'" class="layui-input single-model-select {required:true}" readonly>
                    </div>
                </div>
            </#if>
			<div class="layui-form-item">
                <label class="layui-form-label">应收金额<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="receivableAmount" placeholder="请输入应收金额" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">应退金额<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <input type="text" name="retreatAmount" placeholder="请输入应退金额" class="layui-input {required:true}"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea  name="remark"  class="layui-textarea" maxlength="500"></textarea>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">状态<span class="ui-request">*</span></label>
                <div class="layui-input-block">
                    <select name="status" class="layui-input">
                        <option value="1">未结算</option>
                        <option value="2">已结算</option>
                    </select>
                </div>
            </div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
</html>
